package com.urban.pooling.repository;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.urban.pooling.domain.Route;
import com.urban.pooling.domain.RouteRequest;
import com.urban.pooling.domain.RouteRequestStatus;
import com.urban.pooling.domain.User;

public interface RouteRequestRepository extends CrudRepository<RouteRequest, Integer> {

	public Iterable<RouteRequest> findByRouteAndRouteRequestStatus(Route route, RouteRequestStatus acceptedStatus);

	@Query("FROM RouteRequest rr WHERE rr.route.driver=?1 AND rr.routeRequestStatus.status=?2")
	public Iterable<RouteRequest> findForUserAndByStatus(User user, String status);

}
